﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArmoryAPI
{
    /// <summary>
    /// Represents a title that can be achieved by World of Warcraft players
    /// </summary>
    public class Title
    {
        #region Members

            private String _title;
            private String _characterName;
        
        #endregion

        #region Properties
       
            /// <summary>
            /// The title, including the character's name if the object is being accessed from a character object
            /// </summary>
            public String PlayerTitle
            {
                get
                {
                    if (_characterName == null)
                    {
                        return _title.Replace("%s", String.Empty).Trim();
                    }
                    else
                    {
                        return _title.Replace("%s", _characterName).Trim();
                    }
                }
            }
            
        #endregion

        #region Constructors

            /// <summary>
            /// Constructs a title with a character name that will be included
            /// </summary>
            /// <param name="characterName">The character whom the title will be applied to</param>
            /// <param name="title">The title</param>
            internal Title(String characterName, String title)
            {
                _title = title;
                _characterName = characterName;
            }

            /// <summary>
            /// Constructs a Title with no character name
            /// </summary>
            /// <param name="title">The title</param>
            internal Title(String title)
            {
                _title = title;
                _characterName = null;
            }

            /// <summary>
            /// Constructs an empty Title
            /// </summary>
            public Title()
            {
                _title = String.Empty;
                _characterName = null;
            }
        
        #endregion
    }
}
